System, method and storage medium for controlling asynchronous updates to a register

ABSTRACT

A system for controlling asynchronous updates to a register, the system including a generally accessible register that is asynchronously updateable by hardware and software. The system also includes protection logic that is in communication with the register. The protection logic includes circuitry to prevent a hardware update to the register from being overwritten by a software update.

BACKGROUND OF THE INVENTION

The invention relates to controlling asynchronous updates to a registerin a computer system and in particular, to protecting hardwareasynchronous updates to a register that is simultaneously modifiable bysoftware.

There are many structures within a computer system that can be read andwritten by both hardware and software. These structures generally existfor the purpose of exchanging information (e.g., status, interrupts)between hardware and software. Due to the asynchronous nature of thesestructures, special attention must be paid to how software updates areperformed. A typical register will hold more than one independentlyupdateable field. Hardware updates to each field are automaticallyindependent, but software updates to each field may not be independent.For example, a software update to such a register may include performinga “read-write-modify” operation. This operation instructs the softwareto read the register. If, in the time between the read and the write,the hardware has asynchronously updated a field, the hardware updatewill be lost (overwritten) by the old (stale) value at the completion ofthe read-modify-write operation.

One approach to handling the problem of asynchronous updates is to breakup the register on field boundaries into separately accessibleregisters. This approach requires more registers, which may not alwaysbe available in the hardware system. Another approach to handling theproblem of asynchronous updates is to add locks to fields within theregister. Software would then be responsible for setting and resettinglocks before and after the software updates. This approach is not idealbecause it requires additional software instructions to be executed foreach software update to a register. The execution of the extrainstructions may cause longer execution times. A third approach tohandling the problem of asynchronous updates is to create specialinstructions and hardware for accessing these registers such that afield can be manipulated independently. A drawback of this approach isthat special instructions must be written and accessed to perform datamanipulation. A further approach is to attempt to place critical bitsinto registers that don't get a lot of read-modify-write traffic. Thisworks to a point, but will still fail, just not as often. In addition,new software code (e.g., millicode) is created on a frequent basis.Therefore, a register that is thought at one point in time to have lowtraffic, may not have low traffic at a later time. In addition to thedrawbacks noted above, none of these approaches to handling the problemof asynchronous updates provides a system where registers are generallyaccessible by software, such that the software can perform a singleoperation to read, write and/or read-write-modify the register.

BRIEF SUMMARY OF THE INVENTION

Exemplary embodiments of the present invention include a system forcontrolling asynchronous updates to a storage location. The systemincludes a generally accessible register that is asynchronouslyupdateable by hardware and software. The system also includes protectionlogic that is in communication with the register. The protection logicincludes circuitry to prevent a hardware update to the register frombeing overwritten by a software update.

Additional exemplary embodiments of the present invention include amethod for controlling asynchronous updates to a register. The methodincludes processing a software read instruction for a bit within theregister. The value of the bit is stored in a last read field inresponse to processing the software read instruction. A software writerequest to the bit is received. The current value of the bit is comparedto the last read field. The software write request is processed if thecurrent value of the bit is equal to the last read field.

Further exemplary embodiments include a computer program product forcontrolling asynchronous updates to a register. The computer programproduct includes a storage medium readable by a processing circuit andstoring instructions for execution by the processing circuit forperforming a method that includes a method for controlling asynchronousupdates to a register. The method includes processing a software readinstruction for a bit within the register. The value of the bit isstored in a last read field in response to processing the software readinstruction. A software write request to the bit is received. Thecurrent value of the bit is compared to the last read field. Thesoftware write request is processed if the current value of the bit isequal to the last read field.

BRIEF DESCRIPTION OF THE DRAWINGS

Referring now to the drawings wherein like elements are numbered alikein the several FIGURES:

FIG. 1 is a block diagram of an asynchronous latch update process in asystem where the hardware includes circuitry to set a latch;

FIG. 2 is a flow diagram of a process utilized by an exemplaryembodiment of the present invention to update the data value in anasynchronous latch in a system where the hardware includes circuitry toreset or to set the latch, and the software includes both latch updateand latch read functions;

FIG. 3 is a block diagram of a system for preventing a hardware set tobe overridden by a software write in accordance with exemplaryembodiments of the present invention;

FIG. 4 is a block diagram of an asynchronous latch update process in asystem where the hardware includes circuitry to reset a latch; and

FIG. 5 is a block diagram of a system for preventing a hardware reset tobe overridden by a software write in accordance with exemplaryembodiments of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Exemplary embodiments of the present invention provide for protection ofindividual fields in an asynchronously updateable register that isgenerally accessible by software and updateable by hardware. Generallyaccessible refers to the fact that the register may be accessed bysoftware as a single unit with typical read, write or read-modify-writeinstructions. Without this protection, hardware updates to bits withinthe register may be overwritten by software updates. The individualfields within the register are protected from being overwritten withstale data when a hardware update is made to a field of the registerwhile a read-modify-write operation is pending. Hardware is added to thecritical bits within the register. The additional hardware remembers thelast value read by the software. Then, when the software attempts tomodify the value in the bit, the hardware only allows the modificationif it is clear that the software's value is not stale. That is, if thesoftware has the most current value, the hardware allows themodification to the bit, otherwise the hardware prevents the softwarefrom modifying the bit. An advantage to this approach is that bits thatare known to be critical are protected by hardware. This protection isnot affected by the addition of new functions and/or redefinitions.

FIG. 1 is a block diagram of an asynchronous latch update process in asystem where the hardware includes circuitry to set a latch. FIG. 1depicts the case where the hardware is setting a new value into a bit ina register 100 at the same time that the software is performing aread-modify-write to the register 100. Box 102 represents the register100 with bit w=0, bit x=0, bit y=0 and bit z=0. The software performs aread-modify-write operation to bit z. First, the software reads theregister 100 into box 108 including the values bit w′=0, bit x′=0, bity′=0 and bit z′=0. The software performs its processing and updatesfield z′ resulting in the data values included in box 110. Box 110includes the values bit w′=0, x′=0, y′=0 and z′=1. Before the softwareattempts to write the data back into the register 100, the hardware hasperformed a set operation on bit w as shown in box 104. Box 104 depictsthe values contained in the register 100 including bit w=1, bit x=0, bity=0 and bit z=0. Now, if the software writes the contents of box 110 tothe register 100, the update to bit w, performed by the hardware will beoverwritten. This would result in the register 100 containing invaliddata because the value of bit w read by the software is a stale valueand does not contain the latest update made by the hardware. Exemplaryembodiments of the present invention ensure that the hardware update tobit w is not overwritten by the value read by the software before thehardware update was performed (i.e., that box 106 includes both thehardware update to bit w and the software update to bit z). This resultsin valid data being contained in the register 100 as shown in box 106.

FIG. 2 is a flow diagram of a process utilized by an exemplaryembodiment of the present invention to update the data value in anasynchronous latch in a system where the hardware includes circuitry toeither reset the latch or to set the latch, and the software includesboth latch update and latch read functions. The latch in this exampleincludes protection logic to prevent a software update from overwritinga hardware reset or set operation. At step 202, software reads a datavalue from a latch that corresponds to a bit within a register 100. Thesoftware read is the first step in a read-modify-write operation. Atstep 204, the software performs processing which results in amodification to one or more of the bits in the register 100. Next, atstep 206, the software initiates the writing of a data value into thelatch. A check is made at step 208 to determine if a hardware reset orset was applied to the latch after the software read at step 202. If ahardware reset or set was applied to the latch after the software read,then step 210 is performed to prevent the software from writing to thelatch and leaving the value of “1” in the latch if the hardwareperformed a set operation and a “0” if the hardware performed a resetoperation. If it is determined at step 208, that a hardware reset orhardware set was not applied to the latch after the software read atstep 202, then step 212 is performed and the software writes a datavalue to the latch.

FIG. 3 is a block diagram of exemplary circuitry for preventing ahardware set from being overridden by a software write, in accordancewith exemplary embodiments of the present invention. Typical latchcircuitry 302 within a register that has a hardware set functionincludes a hardware set path 310, a software write path 306, a hold path338 and a software read data path 318. In addition, the latch circuitry302 includes a multiplexor 312, an OR gate 314 and a latch 316 arrangedas depicted in FIG. 3. Protection logic circuitry 304 ensures that ahardware set is not lost during a software write operation. Theprotection logic circuitry 304 includes an AND gate 322, another ANDgate 324, an OR gate 326, a last-read latch 328, an inverter 330 and afurther AND gate 332 arranged as shown in FIG. 3. The protection logiccircuitry 304 remembers the value of the latch 316 at the time of thelast software read in the last-read latch 328. When the last-read latch328 is “0” and the current value of the latch 316 is “1”, the protectionlogic drives a “1” on the protection logic output path 334 to preventsoftware from resetting the latch 316. The protection stays asserteduntil software again reads the latch 316 and sees that the value is now“1”, at which time, the last-read latch 328 is set through path 340. Theprotection logic output path 334 is then de-asserted such that softwarewrites to the latch 316 are possible through the protection logic outputpath 334. The last-read latch 328 stays asserted until the softwarewrites a “0” to the latch 316, at which time the last-read latch 328 isreset through path 342.

The common scenario for which the protection logic circuitry 304 isuseful is when the software is interested in accessing a generallyaccessible register 100 for the purpose of updating one or more fields,for example field/bit “w” as shown in FIG. 1. The softwareread-modify-write to obtain bit w actually accesses the entire register100 including bit w, which may represent an asynchronously updateablefield. Hardware may update bit w during the software read-modify-writeoperation and the value written by the software now has an invalid(stale) value for bit w. The protection logic circuitry 304 detects thisand forces bit w to maintain its current value, overriding the softwareupdate. If the software requires that bit w be updated, it must re-readthe register 100 to obtain the current value in bit w and repeat theprocess described in reference to FIG. 2.

FIG. 4 is a block diagram of an asynchronous latch update process in asystem where the hardware includes circuitry to reset a latch. FIG. 1depicts the case where the hardware is resetting a bit in a register 100at the same time that the software is performing a read-modify-write tothe register 100. Box 402 represents the register 100 with bit w=1, bitx=0, bit y=0 and bit z=0. The software performs a read-modify-writeoperation to bit z. First, the software reads the register 100 into box408 including the values bit w′=1, bit x′=0, bit y′=0 and bit z′=0. Thesoftware performs its processing and updates field z′ resulting in thedata values included in box 410. Box 410 includes the values bit w′=1,x′=0, y′=0 and z′=1. Before the software attempts to write the data backinto the register 100, the hardware has performed a reset operation onbit w as shown in box 404. Box 404 depicts the values contained in theregister 100 including bit w=0, bit x=0, bit y=0 and bit z=0. Now, ifthe software writes the contents of box 410 to the register 100, theupdate to bit w, performed by the hardware will be overwritten. Thiswould result in the register 100 containing invalid data because thevalue of bit w read by the software is a stale value and does notcontain the latest update made by the hardware. Exemplary embodiments ofthe present invention ensure that the hardware update to bit w is notoverwritten by the value read by the software before the hardware updatewas performed (i.e., that box 406 includes both the hardware update tobit w and the software update to bit z). This results in valid databeing contained in the register 100 as shown in box 406.

FIG. 5 is a block diagram of an exemplary system for preventing ahardware reset to be overridden by a software write in accordance withexemplary embodiments of the present invention. Typical latch circuitry502 within a register that includes a hardware reset function includes ahardware reset path 506, a software write path 306, a hold path 338 anda software read data path 318. In addition, the latch circuitry 502includes a multiplexor 312, an OR gate 508, an inverter 510, an AND gate512 and a latch 316 arranged as depicted in FIG. 5. Protection logiccircuitry 504 ensures that a hardware reset is not lost during asoftware write operation. The protection logic circuitry 504 includes aninverter 514, an AND gate 516, an OR gate 520, a last-read latch 328,another inverter 522 and another AND gate 524 arranged as shown in FIG.5. The protection logic circuitry 504 remembers the value of the latch316 at the time of the last software read in the last-read latch 328.When the last-read latch 328 is “1” and the current value of the latch316 is “0”, the protection logic drives a “1” on the protection logicoutput path 526 to prevent software from setting the latch 316. Theprotection stays asserted until software again reads the latch 316 andsees that the value is now “0”, at which time, the last-read latch 328is updated through path 518. The protection logic output path 526 isthen de-asserted such that software writes to the latch 316 are possiblethrough the protection logic output path 526. The last-read latch 328stays de-asserted until the software writes a “1” to the latch 316, atwhich time the last-read latch 328 is set through path 318.

In exemplary embodiments of the present invention, the hardwaredescribed above is a processor and the software is millicode thatexecutes on the processor. For example, the processor may be a serverand the software may be millicode that executes on the processor at acode layer underneath the operating system. In these exemplaryembodiments, the generally-accessible registers as described previouslyare the architected and micro-architected registers of the processor. Inaddition, the asynchronously updateable register as described previouslyis a log-trace control register that generates asynchronous interrupt tothe millicode.

Exemplary embodiments of the present invention allow standardread-modify-write operations to access asynchronously updateableregisters while providing protection against the software instructionoverwriting a value placed in the register by the hardware during aread-modify-write operation. Exemplary embodiments of the presentinvention include attaching protection logic circuitry to bits in aregister that are known to be critical. Advantages to this approach arethat bits that are known to be critical are protected by hardware andthat the hardware protection is not affected by the addition of newfunctions and/or redefinitions.

As described above, the embodiments of the invention may be embodied inthe form of computer-implemented processes and apparatuses forpracticing those processes. Embodiments of the invention may also beembodied in the form of computer program code containing instructionsembodied in tangible media, such as floppy diskettes, CD-ROMs, harddrives, or any other computer-readable storage medium, wherein, when thecomputer program code is loaded into and executed by a computer, thecomputer becomes an apparatus for practicing the invention. Anembodiment of the present invention can also be embodied in the form ofcomputer program code, for example, whether stored in a storage medium,loaded into and/or executed by a computer, or transmitted over sometransmission medium, such as over electrical wiring or cabling, throughfiber optics, or via electromagnetic radiation, wherein, when thecomputer program code is loaded into and executed by a computer, thecomputer becomes an apparatus for practicing the invention. Whenimplemented on a general-purpose microprocessor, the computer programcode segments configure the microprocessor to create specific logiccircuits.

While the invention has been described with reference to exemplaryembodiments, it will be understood by those skilled in the art thatvarious changes may be made and equivalents may be substituted forelements thereof without departing from the scope of the invention. Inaddition, many modifications may be made to adapt a particular situationor material to the teachings of the invention without departing from theessential scope thereof. Therefore, it is intended that the inventionnot be limited to the particular embodiment disclosed as the best modecontemplated for carrying out this invention, but that the inventionwill include all embodiments falling within the scope of the appendedclaims. Moreover, the use of the terms first, second, etc. do not denoteany order or importance, but rather the terms first, second, etc. areused to distinguish one element from another.

1. A system for controlling asynchronous updates to a storage location,the system comprising: a generally accessible register that isasynchronously updateable by hardware and software; and protection logicin communication with the register, wherein the protection logicincludes circuitry to prevent a hardware update to the register frombeing overwritten by a software update.
 2. The system of claim 1 whereinthe register includes one or more bits and the protection logic is incommunication with one of the bits.
 3. The system of claim 1 wherein theregister includes a plurality of bits and the protection logic is incommunication with one or more of the bits.
 4. The system of claim 1wherein the software update is being performed by a read-modify-writeinstruction.
 5. The system of claim 4 wherein the protection logic:remembers the value of the bit read by the software in the read portionof the read-modify-write instruction; compares the value of the bit readby the software to the current value of the bit; and prevents thesoftware from performing the write portion of the read-modify-writeinstruction for the bit if the value of the bit read by the software isnot the same as the current value of the bit.
 6. The system of claim 4wherein the hardware update occurs after the read portion of theread-modify-write instruction and before the write portion of theread-modify-write instruction.
 7. The system of claim 1 wherein thehardware update is a set operation.
 8. The system of claim 1 wherein thehardware update is a reset operation.
 9. The system of claim 1 whereinthe system is a computer processor.
 10. The system of claim 9 whereinthe computer processor is a server
 11. The system of claim 1 wherein thesoftware is millicode.
 12. The system of claim 1 wherein the register isa log-trace control register.
 13. A method of controlling asynchronousupdates to a register, the method comprising: processing a software readinstruction for a bit within the register; storing the value of the bitin a last read field in response to said processing a software readinstruction; receiving a software write request to the bit; comparing acurrent value of the bit to the last read field; and processing thesoftware write request if the current value of the bit is equal to thelast read field.
 14. The method of claim 13 wherein the method isimplemented in computer hardware.
 15. The method of claim 13 wherein thesoftware read instruction and software write request are part of aread-write-modify operation.
 16. The method of claim 13 furthercomprising processing a hardware set operation to the bit after thestoring and before the comparing.
 17. The method of claim 13 furthercomprising processing a hardware rest operation to the bit after thestoring and before the comparing.
 18. The method of claim 13 wherein thesoftware read instruction and software write request are implemented inmillicode.
 19. A computer program product for controlling asynchronousupdates to a register, the computer program product comprising: astorage medium readable by a processing circuit and storing instructionsfor execution by the processing circuit for performing a methodcomprising: processing a software read instruction for a bit within theregister; storing the value of the bit in a last read field in responseto said processing a software read instruction; receiving a softwarewrite request to the bit; comparing a current value of the bit to thelast read field; and processing the software write request if thecurrent value of the bit is equal to the last read field.